//
//  OrderDetaillogisticsCell.m
//  danpin
//
//  Created by chuangjia on 29/10/2015.
//  Copyright © 2015 chuangjia. All rights reserved.
//

#import "OrderDetaillogisticsCell.h"
#import "HorizontalProgressView.h"
@interface OrderDetaillogisticsCell ()
{
    
}
@property(nonatomic,strong)UILabel *noLabel;
@property(nonatomic,strong)UIView *line2view;
@property(nonatomic,strong)HorizontalProgressView*horizontalProgressView;
//


@end
@implementation OrderDetaillogisticsCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor=[UIColor clearColor];
        
        _noLabel =[[UILabel alloc] initWithFrame:CGRectMake(0,0, DEVICE_WIDTH,20)];
        _noLabel.backgroundColor = [UIColor clearColor];
        _noLabel.textColor = CONTEXT_COLOR;
        _noLabel.textAlignment = NSTextAlignmentLeft;
        _noLabel.font = FONT(12);
        [self.contentView addSubview:_noLabel];
        
        _line2view =[[UIView alloc] initWithFrame:CGRectZero];
        _line2view.backgroundColor=UIColorFromRGB(0xcccccc);
        [self.contentView addSubview:_line2view];
        //
        _horizontalProgressView = [[HorizontalProgressView alloc] initWithFrame:CGRectMake(PHOTO_FRAME_WIDTH, PHOTO_FRAME_WIDTH*5, DEVICE_WIDTH-PHOTO_FRAME_WIDTH*2, PHOTO_FRAME_WIDTH*10)];
        _horizontalProgressView.lineMaxHeight = 4;
        _horizontalProgressView.pointMaxRadius = 6;
        _horizontalProgressView.animationDuration = 3;
        _horizontalProgressView.textPosition = topPostion;
        _horizontalProgressView.hidden = YES;
        [self.contentView addSubview:_horizontalProgressView];
        
    }
    return self;
}
-(void)dealloc
{
    self.actionBlock =nil;
    self.data=nil;
    self.indexPath=nil;
    self.other=nil;
    self.key=nil;
    
    //    DLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)drawRect:(CGRect)rect {
    
    [super drawRect:rect];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
}
/// 根据数据模型来显示内容
- (void)showInfo:(id)model key:(id)key indexPath:(NSIndexPath *)indexPath
{
    self.key =key;
    self.indexPath=indexPath;
    NSDictionary *dict =(NSDictionary*)model;
    self.data =model;
    
    _noLabel.frame =CGRectMake(PHOTO_FRAME_WIDTH, PHOTO_FRAME_WIDTH,DEVICE_WIDTH-PHOTO_FRAME_WIDTH*2, 20);
    _noLabel.text = @"订单跟踪";
    _line2view.frame =CGRectMake(PHOTO_FRAME_WIDTH, PHOTO_FRAME_WIDTH+30,DEVICE_WIDTH, 0.5);

    NSArray *temp = [dict arrayObjectForKey:@"status_list"];
    if (temp && [temp isKindOfClass:[NSArray class]]) {
        NSMutableArray *array =[NSMutableArray arrayWithArray:temp];
        if (array.count>0) {
            _horizontalProgressView.hidden = NO;
            NSMutableArray *nameArray = [NSMutableArray array];
            int currentLevel = 0;
            for (int i=0; i<array.count; i++) {
                NSDictionary *obj = [array objectAtIndex:i];
                NSString *name = [obj stringForKey:@"name" withDefaultValue:@""];
                if ([[obj numberStringForKey:@"is_cur_id"] intValue]==1) {
                    currentLevel = i;
                }
                [nameArray addObject:name];
            }
            _horizontalProgressView.frame = CGRectMake(PHOTO_FRAME_WIDTH, PHOTO_FRAME_WIDTH*5, DEVICE_WIDTH-PHOTO_FRAME_WIDTH*2, PHOTO_FRAME_WIDTH*10);
            _horizontalProgressView.progressLevelArray = nameArray;
            _horizontalProgressView.currentLevel = currentLevel;
        }
      
    }
   
    [self layoutSubviews];
}
-(void)setCallBack:(void(^)(BEventType,UIView*,id,id,NSIndexPath *))callback
{
    self.actionBlock=callback;
}
/// 返回Cell高度
+ (CGFloat)returnCellHeight:(id)model
{
    return PHOTO_FRAME_WIDTH*13;
}
@end
